package jin.si.com.suo;

import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

/**
 * @description:
 * @ClassName MyRunnable
 * @Author MT
 * @Date 2021/7/4 14:18
 **/
public class MyRunnable2 implements Runnable{

    private int number=2000;

    //创建lock锁
    Lock lock=new ReentrantLock();

    @Override
    public void run() {

        while (true){
            lock.lock();
            if(number>0){
                System.out.println(Thread.currentThread().getName()+"："+number);
                number--;
            }else{
                break;
            }
            lock.unlock();
        }
    }



}
